﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using PSE.Communication.Fix.Common.Fixml.Enum;

namespace PSE.Communication.Fix.Common.Fixml
{
    [XmlRoot("AllocInstrctnAck")]
    public class AllocationInstructionAck
    {
        [XmlAttribute("ID")]
        public string AllocationID { get; set; }
        
        // Mapeamento do enum para o codigo de erro
        [XmlIgnore]
        public AllocationInstructionAckStatus AllocationStatus {
            get { return (AllocationInstructionAckStatus)Convert.ToInt32(AllocationStatusCode); }
            set { AllocationStatusCode = Convert.ToString(value); }
        }
        
        [XmlAttribute("Stat")]
        public string AllocationStatusCode { get; set; }
        
        [XmlAttribute("RejCode")]
        public string AllocationRejectCode { get; set; }
        
        [XmlIgnore]
        public string AllocationRejectMessage
        {
            get { return Constants.Instance.GetBusinessErrorMessage(AllocationRejectCode); }
        }
        
        [XmlElement("Alloc", IsNullable = false)]
        public AllocationDataAck AllocationDataAck { get; set; }
    }
}
